package com.woniuxy.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.domain.Ticket;
import com.woniuxy.dto.JsonResultDto;
import com.woniuxy.param.SeatXYParam;
import com.woniuxy.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wuyanzu
 * @since 2021-05-26
 */
@RestController
@RequestMapping("/ticket")
public class TicketController {
    @Autowired
    private TicketService ticketService;
    @GetMapping("/selectValidTicketByXY")
    public JsonResultDto selectValidTicketByXY(SeatXYParam seatXYParam){
        return ticketService.selectValidTicketByXY(seatXYParam);
    }
    @GetMapping("/changeTicketOrder")
    public boolean changeTicketOrder(Ticket ticket){
        return ticketService.changeTicketOrder(ticket);
    }
    @PutMapping("/changeOrderSuccess")
    public boolean changeOrderSuccess(Ticket ticket){
        ticket.settStatus("0");
        return ticketService.updateById(ticket);
    }
    @PutMapping("/changeOrderFailed")
    public boolean changeOrderFailed(Ticket ticket){
        ticket.settStatus("1");
        return ticketService.updateById(ticket);
    }
    @PutMapping
    public boolean changeOrderOver(Ticket ticket){
        ticket.settStatus("1");
        return ticketService.updateById(ticket);
    }
    @GetMapping("/selectTicketByCode")
    public Ticket selectTicketByCode(String code){
        return ticketService.getOne(new QueryWrapper<Ticket>().eq("ticket_code",code));
    }

}

